home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / doflag.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  50 lines

  1. /*****************************************************************************
  2.  
  3.     DoFlag()
  4.  
  5.     This function gets or sets the value of a TECO mode control flag.
  6.  
  7.     The TECO mode control flags are ED, EH, ES, ET, EU, EV, EZ and ^X.
  8. The EO flag can only be examined,  not set,  so ExeEO does not call this
  9. function.
  10.  
  11. *****************************************************************************/
  12.  
  13. #include "zport.h"        /* define portability identifiers */
  14. #include "tecoc.h"        /* define general identifiers */
  15. #include "defext.h"        /* define external global variables */
  16.  
  17. DEFAULT DoFlag(Flag)        /* handle a mode control flag */
  18. WORD *Flag;
  19. {
  20.     DBGFEN(2,"DoFlag",NULL);
  21.  
  22.     if ((EStTop == EStBot) ||            /* if no numeric arg or */
  23.         (EStack[EStTop].ElType != OPERAND)) {   /* partial expression */
  24.         DBGFEX(2,DbgFNm,"PushEx");
  25.         return PushEx((LONG)*Flag, OPERAND);    /* return the flag */
  26.     }
  27.  
  28.     if (GetNmA() == FAILURE) {        /* get the numeric argument */
  29.         DBGFEX(2,DbgFNm,"FAILURE, GetNmA() failed");
  30.         return FAILURE;
  31.     }
  32.  
  33.     if ((CmdMod & MARGIS) == '\0') {    /* if it's n<flag> */
  34.         *Flag = (WORD)NArgmt;        /* set the flag to n */
  35.     } else if (MArgmt && NArgmt) {        /* else if it's m,n<flag> */
  36.         *Flag &= (WORD)~MArgmt;        /* turn off m bits */
  37.         *Flag |= (WORD)NArgmt;        /* turn on n bits */
  38.     } else if ((MArgmt == 0) && NArgmt) {    /* else if it's 0,n<flag> */
  39.         *Flag |= (WORD)NArgmt;        /* turn on n bits */
  40.     } else if ((MArgmt) && (NArgmt == 0)) {    /* else if it's m,0<flag> */
  41.         *Flag &= (WORD)~MArgmt;        /* turn off m bits */
  42.     }
  43.  
  44.     EStTop = EStBot;            /* clear expression stack */
  45.     CmdMod = '\0';                /* clear modifiers flags */
  46.  
  47.     DBGFEX(2,DbgFNm,"SUCCESS");
  48.     return SUCCESS;
  49. }
  50.